<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<?=gurl('css');?>/admin.css" />
<script language="javascript" src="<?=gurl('js');?>/jq.js"></script>
<script language="javascript" src="<?=gurl('js');?>/common.js"></script>
<script src="<?=gurl('js');?>/my97/WdatePicker.js"></script>
<script type="text/javascript" src="<?=gurl('js');?>/sites.js"></script>
</head>
<body>
	<h3 style="background:#E5ECF3; padding:5px; font-size:12px;">> <a href="<?=site_url(rnadminpath().'/main/show/main');?>">首页</a> > <a href="#">增加广告</a></h3>
	<div style="margin-top:10px;padding:5px;border:1px solid #9FACB7;">
	<form action="" method="POST" onSubmit="return add_ads();" enctype="multipart/form-data">
		<ul class="additem" style="width:500px;text-align:left;margin:0 auto;">
			<li>广告位：<select name="placeid" id="placeid">
			<option value="0">请选择广告位</option>
			<? foreach ($places as $place):?>
			<option <? if($placeid == $place["placeid"]):?> selected <? endif;?> value="<?=$place["placeid"];?>"><?=$place["placename"];?></option>
			<? endforeach;?>
			</select></li>
			<li>广告名称：<input class="textinput" type="text" name="adsname" id="adsname" dataType="Require" msg="请输入名称" /></li>
			<li>广告内容：<input class="textinput" type="file" name="	imageurl" id="imageurl" dataType="Require" msg="请选择图片" /></li>
			<li>广告链接：<input class="textinput" type="text" name="	linkurl" id="linkurl" dataType="Require" msg="请输入链接" /></li>
			<li>发布日期：<input class="textinput" type="text" name="fromdate" id="fromdate" onClick="WdatePicker()" dataType="Require" msg="请输入发布日期" /></li>
			<li>结束日期：<input class="textinput" type="text" name="todate" id="todate" onClick="WdatePicker()" /></li>
			<li>是否启用：<input  type="radio" name="passed" id="passed" value="1" checked />是&nbsp;<input  type="radio" name="passed" id="passed" value="0" />否&nbsp;</li>
			<? if($current_place['forsite'] == '1'):?>
			<li>应用小站：
			<input type="text" name="keyword" id="keyword" class="searchWord" value="<?=$keyword;?>" />
			<select name="topclass" id="topclass" onChange="aj_change_class(this.value)">
					 <option value="">请选择</option>
					<? foreach($topclass as $class):?>
						<option value="<?=$class['id'];?>" <? if($topclassid == $class['id']):?> selected <? endif;?>><?=$class['name'];?></option>
					<? endforeach;?>
			</select> <select name="subclass" id="subclass">
				  	<option value="">请选择</option>
					<? foreach($subclass as $class):?>
						<option value="<?=$class['id'];?>" <? if($subclassid == $class['id']):?> selected <? endif;?>><?=$class['name'];?></option>
					<? endforeach;?>
			</select>
			&nbsp;
			<input type="button" value="搜索" class="searchIco" onClick="window.location='<?=gurl(rnadminpath().'/ads/add/?placeid='.$placeid);?>&keyword='+$('#keyword').val()+'&topclass='+$('#topclass').val()+'&subclass='+$('#subclass').val()+'&do=1'" />
			</li>
			<li>
			<select multiple id="select1" style="vertical-align:top;width:180px;height:250px;">  
			<? foreach ($sitelists as $s):?>
				<option value="<?=$s["id"];?>"><?=$s["name"];?>(<?=$s["domain"];?>)</option> 
			<? endforeach;?>
			</select>  
			&nbsp;&nbsp;&nbsp;&nbsp;
			<select multiple id="select2" name="select2" style="vertical-align:top;width:180px;height:250px;">  
			</select>  
			</li>
			<li><a href="javascript:void(0);" id="add">选中添加到右边&gt;&gt;</a><br>
			<a href="javascript:void(0);" id="addAll">全部添加到右边&gt;&gt;</a>
			</li>
			<? endif;?>
			<li><input type="submit" name="dosubmit" id="dosubmit" value="添加">
			<input type="button" onClick="window.history.go(-1);" value="返回">
			</li>
		</ul>
		<input type="hidden" name="sites" id="sites" value="">
	</form>
	</div>
<script type="text/javascript">  
	function add_ads()
	{
		//获取用户
		var count=$("#select2 option").length; 
		var sites = "";
		for(var i=0;i<count;i++) 
	    {    
	    	sites += "," + $("#select2 ").get(0).options[i].value;
	    } 
	    var placeid = $("#placeid").val();
	    var adsname = $("#adsname").val();
	    var imageurl = $("#imageurl").val();
	    var fromdate = $("#fromdate").val();
	    var todate = $("#todate").val();
	    var passed = $("#passed").val();
	    if(placeid == "") {
	    	alert("请选择广告位");
	    	return false;
	    } else if(adsname == "") {
	    	alert("请输入名称");
	    	return false;
	    } else if(imageurl == "") {
	    	alert("请选择图片");
	    	return false;
	    } else if(fromdate == "") {
	    	alert("请输入发布日期");
	    	return false;
	    } 
	    $("#sites").val(sites);
	    return true;
	}
	
   $(document).ready(function(){  
	   $('#add').click(function(){  
		   var $options = $('#select1 option:selected');//获取当前选中的项  
		   var $remove = $options.remove();//删除下拉列表中选中的项  
		   $remove.appendTo('#select2');//追加给对方  
	   });  
	  $('#addAll').click(function(){  
		  var $options = $('#select1 option');  
		  $options.appendTo('#select2');  
	  });  	         
	  //双击事件  
	  $('#select1').dblclick(function(){   
		  var $options = $('option:selected', this);//注意此处“option”与“:”之间的空格，有空格是不可以的  
		  $options.appendTo('#select2');  
	  });  	         
	  $('#select2').dblclick(function(){  
		  $('#select2 option:selected').appendTo('#select1');  
	  });     
  });  
</script>  
</body>
</html>
